/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.migracion.pool;

import org.antlr.stringtemplate.StringTemplate;

/**
 *
 * @author stevenziggiz
 */
public class MySQL extends DriverConnectionPool implements DataBaseConnection{
    
    static {
        DATA_BASE_TYPE = "MySQL";
    }

    private MySQL() {
        setTablesList("SELECT table_name FROM information_schema.tables WHERE table_schema = '"+this.getDataBaseName()+"' ORDER BY table_name;");
        setColumnsList("Show COLUMNS IN $TABLE_PARAM$ FROM "+this.getDataBaseName()+";");
    }

    public MySQL(String ipServer, int port, String dataBaseName, String user, String password) {
        DRIVER_NAME = "org.gjt.mm.mysql.Driver";
        URL = new StringTemplate("jdbc:mysql://$HOST$:$PORT$/$DATABASE$");
        //Cambia las variables definidas en el Template por los valores correspondientes
        URL.setAttribute("HOST", ipServer);
        URL.setAttribute("PORT", port);
        URL.setAttribute("DATABASE", dataBaseName);
        this.user = user;
        this.password = password;
        this.setDataBaseName(dataBaseName);
        setTablesList("SELECT table_name FROM information_schema.tables WHERE table_schema = '"+this.getDataBaseName()+"' ORDER BY table_name;");
        setColumnsList("Show COLUMNS IN $TABLE_PARAM$ FROM "+this.getDataBaseName()+";");
    }
        
}
